#include "InputHandler.hpp"
#include <iostream>

_NNU_DGGS_BEGIN
    namespace DGGSViewer {

InputHandler::InputHandler() {
}

InputHandler::~InputHandler() {
}

char InputHandler::handleKeyEvent(const SDL_Event& event) {
    if (event.type == SDL_KEYDOWN) {
        SDL_Keycode keycode = event.key.keysym.sym;
        
        // 将按键转换为小写字符
        if (keycode >= SDLK_a && keycode <= SDLK_z) {
            return 'a' + (keycode - SDLK_a);
        } else if (keycode == SDLK_o) {
            return 'o';
        } else if (keycode == SDLK_q) {
            return 'q';
        } else if (keycode == SDLK_r) {
            return 'r';
        } else if (keycode == SDLK_f) {
            return 'f';
        } else if (keycode >= SDLK_1 && keycode <= SDLK_7) {
            // 处理数字键1-7
            return '1' + (keycode - SDLK_1);
        } else if (keycode == SDLK_UP) {
            // 处理上方向键
            return 'u'; // 上
        } else if (keycode == SDLK_DOWN) {
            // 处理下方向键
            return 'd'; // 下
        }
    }
    
    return '\0';
}

}
_NNU_DGGS_END